import request from "@/utils/request";

/**
 * 事件节点/消费者节点 获取节点名称 节点显示名称
 */
export const nodeLabelList = () => {
  return request({
    url: "/rabbit/topology/serverList",
    method: "get",
    params: {
      serverId: "jzt-cloud-dbo",
      serverName: "运营服务"
    }
  });
};

/**
 * 创建节点
 * @param {NodeParams} data
 */
export const createNode = data => {
  return request({
    url: "/rabbit/topology/createNode",
    method: "post",
    data
  });
};

/**
 * 更新节点
 * @param {NodeParams} data
 */
export const updateNode = data => {
  return request({
    url: "/rabbit/topology/updateNode",
    method: "post",
    data
  });
};

/**
 * 删除节点
 * @param { string } id -节点id
 */
export const deleteNode = id => {
  return request({
    url: "/rabbit/topology/deleteNode",
    method: "post",
    params: { id }
  });
};

/**
 * 根据节点类型获取节点列表
 * @param { string } type -节点类型 MQ,SERVER,EVENT,CUSTOMER_QUEUE
 * @returns { NodeParams[] }
 */
export const nodeListByType = type => {
  return request({
    url: "/rabbit/topology/list",
    method: "get",
    params: { type }
  });
};

/**
 * 根据父Id获取节点列表
 * @param { string } parentId
 * @returns { NodeParams[] }
 */
export const nodeListByParentId = parentId => {
  return request({
    url: `/rabbit/topology/child/${parentId}`,
    method: "get"
  });
};
